001 /**
002 * Created by IntelliJ IDEA.
003 * User: Wei Wang
004 * Date: Nov 28, 2002
005 * Time: 10:30:02 AM
006 */
007
008 package EVolve.util.painters;
009
010 import EVolve.visualization.AutoImage;
011 import EVolve.Scene;
012
013 public class BarChartPainter extends Painter{
014 private int[] value; // value of the bars
015 private long xMax;
016
017
018 public BarChartPainter(int size) {
019 value = new int[size];
020 xMax = 0;
021 for (int i = 0; i < value.length; i++) {
022 value[i] = 0;
023 }
024 }
025
026 public String getName() {
027 return "Bar Chart Painter";
028 }
029
030 public void paint(AutoImage image, long x, long y, long z) {
031
032 image.setColor(value[(int)y]++,(int)y,Scene.getColor());
033 if (xMax < value[(int)y])
034 xMax = value[(int)y];
035 }
036
037 public long getxMax() {
038 return xMax;
039 }
040
041 public int[] getValue() {
042 return value;
043 }
044
045 public Object clone() {
046 BarChartPainter o = null;
047 o = (BarChartPainter)super.clone();
048
049 o.value = new int[value.length];
050 for (int i=0; i<value.length; i++)
051 o.value[i] = value[i];
052
053 return o;
054 }
055 }